
local allListerEventList = {}
function FireEvent(name, ...)
    local eventFunList = allListerEventList[name];
    if eventFunList ~= nil then
        for k,v in pairs(eventFunList) do
            if v and v.f ~= nil then
                if v.tb then
                    v.f(v.tb,...)
                else
                    v.f(...)
                end
            end
        end

    end
end
function CloseAllEvent()
    table.clear(allListerEventList)
end

--listen一个事件
---@param tbl table
 function ListenEvent(eventType, func, tbl)
    local evList = allListerEventList[eventType]
     if  evList == nil then
         evList = {}
         allListerEventList[eventType] = evList;
     end
    for k,v in pairs(evList) do
        if v.f == func and v.tb == tbl then
            return
        end
    end
     table.insert(evList,{f = func,tb = tbl});

 end
--关闭一个事件
function CloseEvent(name,func,tb)
    local eventList = allListerEventList[name];
    if eventList ~= nil then
        for k,v in pairs(eventList) do
            if v.f == func then
                if v.tb == nil or v.tb == tb then
                    table.remove(eventList,k)
                    break
                end
            end
        end
    end
end
